home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / EXAMPLES / IFC / IFC.C next >
C/C++ Source or Header  |  1992-03-27  |  3KB  |  86 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * File chooser main program.
  25.  */
  26.  
  27. #include <InterViews/filechooser.h>
  28. #include <InterViews/world.h>
  29. #include <stdlib.h>
  30. #include <iostream.h>
  31. #include <string.h>
  32.  
  33. static PropertyData properties[] = {
  34.     { "ifc*caption", "Please select a file:" },
  35.     { "ifc*subcaption", "" },
  36.     { "ifc*rows", "10" },
  37.     { "ifc*cols", "24" },
  38.     { "ifc*accept", " Open " },
  39.     { "ifc*static", "true" },           // original: "false"
  40.     { nil }
  41. };
  42.  
  43. static OptionDesc options[] = {
  44.     { "-caption", "ifc*caption", OptionValueNext },
  45.     { "-subcaption", "ifc*subcaption", OptionValueNext },
  46.     { "-rows", "ifc*rows", OptionValueNext },
  47.     { "-cols", "ifc*cols", OptionValueNext },
  48.     { "-accept", "ifc*accept", OptionValueNext },
  49.     { "-static", "ifc*static", OptionValueImplicit, "true" },
  50.     { nil }
  51. };
  52.  
  53. int IVMain (int argc, char** argv) {
  54.     World* world = new World("ifc", properties, options, argc, argv);
  55.     const char* dir = (argc == 2) ? argv[1] : "~";
  56.     const char* _static = world->GetAttribute("static");
  57.     boolean transient = _static == nil || strcmp(_static, "true") != 0;
  58.     int status = 0;
  59.  
  60.     FileChooser* chooser = new FileChooser(
  61.     world->GetAttribute("caption"),
  62.     world->GetAttribute("subcaption"),
  63.     dir,
  64.     atoi(world->GetAttribute("rows")),
  65.     atoi(world->GetAttribute("cols")),
  66.     world->GetAttribute("accept")
  67.     );
  68.  
  69.     chooser->SetName("InterViews file chooser");
  70.     chooser->SetIconName("ifc");
  71.  
  72.     world->InsertApplication(chooser);
  73.     chooser->SelectFile();
  74.  
  75.     do {
  76.     status = chooser->Accept() ? 0 : 1;
  77.     if (status == 0) {
  78.         const char* s = chooser->Choice();
  79. //            cout << chooser->Choice() << "\n";
  80. //            cout.flush();
  81.     }
  82.     } while (!transient && status == 0);
  83.  
  84.     return status;
  85. }
  86.